﻿using Avalonia;
using Avalonia.Media;
using CommunityToolkit.Mvvm.ComponentModel;
using SukiUI;

namespace AvaloniaApplicationDemo.ViewModels;

public partial class HomePageViewModel : ObservableObject
{
    [ObservableProperty] private string _title = "DashBoard";
    [ObservableProperty] private IBrush _background = CreateLightGradient();

    public HomePageViewModel()
    {
        SukiTheme.GetInstance().OnBaseThemeChanged += themeChanged =>
        {
            Background = themeChanged.Key.Equals("dark") ? CreateDarkGradient() : CreateLightGradient();
        };
    }


    // 创建深色渐变
    private static IBrush CreateDarkGradient()
    {
        return new LinearGradientBrush
        {
            StartPoint = new RelativePoint(0, 0, RelativeUnit.Relative),
            EndPoint = new RelativePoint(1, 1, RelativeUnit.Relative),
            GradientStops = new GradientStops
            {
                new GradientStop { Color = Colors.HotPink, Offset = 0 },
                new GradientStop { Color = Color.FromRgb(204, 204, 255), Offset = 1 }
            }
        };
    }

    // 创建亮色渐变
    private static IBrush CreateLightGradient()
    {
        return new LinearGradientBrush
        {
            StartPoint = new RelativePoint(0, 0, RelativeUnit.Relative),
            EndPoint = new RelativePoint(1, 1, RelativeUnit.Relative),
            GradientStops = new GradientStops
            {
                new GradientStop { Color = Colors.Purple, Offset = 0 },
                new GradientStop { Color = Color.FromRgb(204, 204, 255), Offset = 1 }
            }
        };
    }
}